package controller.thread_pool_solver;

import java.util.LinkedList;

public class LimitedQueue<T> extends LinkedList<T> {
	private static final long serialVersionUID = 1L;
	private final int maxSize;
	
	public LimitedQueue(int maxSize) {
		if(maxSize < 0)
			throw new IllegalArgumentException("negative size");
		this.maxSize = maxSize;
	}
	
	public boolean offer(T e) {
		super.offer(e);
		if(size() > maxSize)
			super.poll();
		return true;
	};

}
